package com.electronicmallapiidea.common;
import com.electronicmallapiidea.constants.Constants;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 后端统一返回结果
 * @param
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result implements Serializable {

    private String code; //编码：1成功，0和其它数字为失败
    private String msg; //错误信息
    private Object data; //数据

    public static Result success( ){
        return new Result(Constants.CODE_200,null,null);
    }
    public static Result success(Object data){
        return new Result(Constants.CODE_200,null,data);
    }
    public static Result error(){
        return new Result(Constants.CODE_500,null,null);
    }
    public static Result error(String code,String msg){
        return new Result(code,msg,null);
    }



}
